package com.smartmail.utility;

public class UnitsConventer {
	public static String convert(long what){
		long actSize = what;
		String jednostka = "B";
		long rest = 0;
		if (actSize > 1023){
			// na kB
			rest = actSize % 1024;
			actSize /= 1024;			
			jednostka = "kB";
			if (actSize > 1023){
				// na mB
				rest = actSize % 1024;
				actSize /= 1024;		
				jednostka = "mB";
			}			
		}
		if (rest > 999) rest /= 100;
		else if (rest > 99) rest /= 10;
		return String.valueOf(actSize) + "," + String.valueOf(rest) + " " + jednostka;
	}
}
